﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BaseDatos;

namespace SCHD
{
    public partial class WFListFormularios : TDV.Controles.Base.WinForm.BaseForm_Tipo01
    {
        public WFListFormularios()
        {
            InitializeComponent();
        }
        public string CodigoFormulario = "";
        public bool Tipo = false;
        private string codigo = "";
        public WFListFormularios(string Codigo)
            :this()
        {
            this.codigo = Codigo;
        }

        private void WFListFormularios_Load(object sender, EventArgs e)
        {
            CargaLista(codigo);
        }
        protected void CargaLista(string cod)
        {
            try
            {
            GrdListaFormularios.DataSource = null;
            if (!string.IsNullOrEmpty(cod))
            {
                string SQL = "" +
                    "select  codform, nomform from chdformularios where codform not in (" + cod + ") and flgeli ='0'";
                DataSet dsLista = ConexionBaseDatos.Conexion.CrearDataSet(SQL, CommandType.Text);
                if (dsLista.Tables[0].Rows.Count > 0)
                {
                    GrdListaFormularios.DataSource = dsLista.Tables[0];
                }
            }
            else
            {
                string SQL = "" +
                        "select  codform, nomform from chdformularios where flgeli ='0'";
                DataSet dsLista = ConexionBaseDatos.Conexion.CrearDataSet(SQL, CommandType.Text);
                if (dsLista.Tables[0].Rows.Count > 0)
                {
                    GrdListaFormularios.DataSource = dsLista.Tables[0];
                }
            }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void BtnAceptar_Click(object sender, EventArgs e)
        {
            CodigoFormulario = GrdListaFormularios.CurrentRow.Cells[0].Value.ToString();
            Tipo = RdRegistro.Checked;
            DialogResult = DialogResult.OK;
        }

        private void BtnCancelar_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }

    }
}
